<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDatamasterTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('users', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('username',100)->unique();
            $table->string('email',100)->unique();
            $table->string('name', 100);
			$table->string('password', 100);
			$table->string('group_id', 100);
            // required for Laravel 4.1.26
			$table->boolean('is_enabled');
            $table->string('remember_token', 100)->nullable();
			$table->datetime('last_login');
            $table->timestamps();
		});
        Schema::create('group', function(Blueprint $table)
		{
			$table->string('id',100);
            $table->primary('id');
            $table->string('name',100);
            $table->string('description',100)->nullable();
            $table->boolean('is_enabled');
            $table->timestamps();
		});
        Schema::create('Module', function(Blueprint $table)
		{
			$table->string('id',100);
			$table->primary('id');
            $table->string('name',100);
			$table->integer('sequence');
            $table->string('icon',100);
            $table->boolean('is_enabled');
            $table->boolean('is_show');
			$table->timestamps();
		});
		Schema::create('functions', function(Blueprint $table)
		{
            $table->string('id',100);
            $table->primary('id');
			$table->string('name',100);
            $table->string('module_id',100);
            $table->string('url',100);
            $table->string('icon',100);
            $table->integer('sequence');
            $table->boolean('is_enabled');
            $table->boolean('is_show');
            $table->timestamps();
		});
		Schema::create('privilegeinfo', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('group_id',100);
			$table->string('module_id',100);
			$table->string('functions_id',100);
			$table->boolean('is_allow_access');
			$table->timestamps();
		});
        
        
        Schema::create('status', function(Blueprint $table)
		{
			$table->string('id',100);
            $table->primary('id');
            $table->string('name',100);
            $table->text('description');
            $table->timestamps();
		});
        Schema::create('project', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('name',100);
			$table->text('description')->nullable();
			$table->date('start_date');
			$table->date('due_date');
			$table->integer('users_username');
            $table->timestamps();
		});
        Schema::create('priority', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('name',100);
            $table->integer('level');
			$table->text('description');
			$table->timestamps();
		});
		Schema::create('log', function(Blueprint $table)
		{
			$table->increments('id');
            $table->integer('record_id');
            $table->string('module_id',100);
            $table->string('status_id',100);
            $table->text('note');
            $table->integer('created_by');
			$table->timestamps();
		});
        
        /*
        Schema::create('task', function(Blueprint $table)
		{
			$table->increments('id');
            $table->string('name',100);
            $table->date('start_date');
            $table->date('due_date');
            $table->text('note')->nullable();
            $table->integer('priority_id');
            $table->integer('status_id');
            $table->integer('project_id');
            $table->integer('created_by');
            $table->integer('updated_by');
            $table->timestamps();
		});
        Schema::create('issue', function(Blueprint $table)
		{
			$table->increments('id');
            $table->string('name',100);
            $table->text('note')->nullable();
            $table->integer('tag_id');
            $table->integer('status_id');
            $table->integer('task_id');
            $table->integer('created_by');
            $table->integer('updated_by');
			$table->timestamps();
		});
        Schema::create('comment', function(Blueprint $table)
		{
			$table->increments('id');
            $table->text('comment_detail');
            $table->integer('issue_id');
            $table->integer('created_by');
			$table->timestamps();
		});
        */
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('users');
		Schema::drop('group');
		Schema::drop('project');
		Schema::drop('status');
		Schema::drop('log');
		Schema::drop('priority');
		Schema::drop('module');
		Schema::drop('functions');
		Schema::drop('privilegeinfo');
	}

}
